package com.yanqu.road.server.cmd.activity.zhounianturntable;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.activity.ZhouNianTurntableProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.zhounianturntable.CrossZhouNianTurntableMgr;
import com.yanqu.road.server.manager.activity.zhounianturntable.ZhouNianTurntableActivity;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_ZHOUNIAN_TURNTABLE_ACTIVITY_UPLOAD_RECORD, desc = "公告上传")
public class CrossZhouNianTurntableUploadRecordCmd extends CrossCommand {

    int activityId;
    PlayerProto.PlayerBaseTempMsg player;
    String reward;
    long playerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ZhouNianTurntableProto.CrossTurntableRecordUploadRecordReqMsg reqMsg = ZhouNianTurntableProto.CrossTurntableRecordUploadRecordReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        player = reqMsg.getPlayer();
        reward = reqMsg.getReward();
        playerId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ZhouNianTurntableActivity activity = CrossZhouNianTurntableMgr.getZhouNianTurntableActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_ZHOUNIAN_TURNTABLE_NO_OPEN;
            return;
        }

        activity.uploadRecord(playerId, reward, PlayerBasePb.parseToUserBaseInfo(player));
    }

    @Override
    public void sendData() {

    }
}
